package org.mall.modules.product.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.mall.modules.pojo.product.dto.ProductSkuDecreaseNumDTO;
import org.mall.modules.product.entities.ProductSkuDO;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;

@Repository
@Mapper
public interface ProductSkuMapper {

    ProductSkuDO selectById(Long id);

    List<ProductSkuDO> selectByIds(@Param("ids") Collection<Long> ids);

    List<ProductSkuDO> selectListBySpuIdAndStatus(@Param("spuId") Long spuId,
                                                  @Param("status") Integer status);

    void insertList(@Param("productSkuDOs") List<ProductSkuDO> productSkuDOs);

    int update(ProductSkuDO productSkuDO);

    int updateToDeleted(@Param("ids") List<Long> ids);

    boolean decreaseProductSkuQuantity(@Param("id") Long id, @Param("quantity") Integer quantity);

    boolean recoveryProductSkuQuantity(@Param("list") Collection<ProductSkuDecreaseNumDTO> dtos);
}
